const merge = require('lodash.merge');
const commonEnvConfig = require('./common');
const devConfig = require('./dev');
const testConfig = require('./test');
const prodConfig = require('./prod');

const getEnvConfig = (env) => {
  switch (env) {
    case 'local':
    case 'dev':
      return merge(commonEnvConfig, devConfig);
      break;
    case 'test':
      return merge(commonEnvConfig, testConfig);
      break;
    default:
      return merge(commonEnvConfig, prodConfig);
  }
};

module.exports = (env) => {
  const envs = {};
  const envConfig = getEnvConfig(env);
  for (const key in envConfig) {
    envs[`${key}`] = JSON.stringify(envConfig[key]);
  }

  return envs;
};
